package com.kanshu.ksgb.fastread.doudou.module.bookcity.adapter;

import android.content.Context;
import android.graphics.Color;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;
import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.common.imageloader.GlideImageLoader;
import com.kanshu.ksgb.fastread.doudou.common.business.commonbean.BookInfo;
import com.kanshu.ksgb.fastread.doudou.common.business.utils.BookUtils;

import java.util.List;

/**
 * 排行榜-完本适配器
 * Created by wcy on 18/5/24.
 */
public class RankingFinishedAdapter extends BaseQuickAdapter<BookInfo> {
    public RankingFinishedAdapter(Context context, List<BookInfo> data) {
        super(context, data);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_ranking_end_book_layout;
    }

    @Override
    protected void convert(BaseViewHolder holder, BookInfo item, int position) {
        holder.setText(R.id.book_title, item.book_title)
                .setText(R.id.desc, item.book_intro)
                .setText(R.id.people_num, item.last_chapter_date + " 完结");
        GlideImageLoader.load(item.cover_url, holder.getView(R.id.cover));
        position = position - getHeaderViewsCount();
        if (position < 3) {
            holder.setTextColor(R.id.ranking, Color.parseColor("#ff5a4d"));
        } else {
            holder.setTextColor(R.id.ranking, Color.parseColor("#ffa889"));
        }
        holder.setText(R.id.ranking, BookUtils.getRankingNum(position));

    }
}
